/*
 * ============================================================================
 * Copyright Notice!
 * ----------------------------------------------------------------------------
 * This file contains proprietary and confidential information belonging to the
 * group of people involvled in developing this project.  Reproduction, disclosure 
 * or use without specific written authorization from project stake holders is 
 * prohibited. Please refer the readme.txt in project installation folder for more
 * specific contacts
 *
 * All rights reserved.
 * ============================================================================
 */
package edu.uwm.universitydb.dao.project.management;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import edu.uwm.universitydb.framework.transactional.db.command.impl.TransactionalDBFetchCommandBase;

/**
 * <code>FetchProjectManagerIdCommand</type>
 * 
 * Command class to fetch project manager id
 * 
 * @author Shyam Nair
 */
public class FetchProjectManagerIdCommand extends TransactionalDBFetchCommandBase<String>
{

    /** static string holding the column name for ssn */
    private static final String TUPLE_COLUMN_PROF_SSN = "prof_ssn";

    /** static string holding the select query */
    private static final String SELECT_QUERY = "select " + TUPLE_COLUMN_PROF_SSN
        + " from university.manage where pno = ?;";

    /** attribute for project number */
    private final Integer mProjectNumber;

    /**
     * 
     * @param projectNumber
     */
    public FetchProjectManagerIdCommand(final Integer projectNumber)
    {
        mProjectNumber = projectNumber;
    }

    /*
     * (non-javadoc)
     * @see edu.uwm.universitydb.framework.db.command.DataFetchCommand#processResult(java.sql.ResultSet)
     */
    @Override
    public String processResult(final ResultSet result) throws SQLException
    {
        if (result.next())
        {
            return result.getString(TUPLE_COLUMN_PROF_SSN);
        }
        return null;
    }

    /*
     * (non-javadoc)
     * @see edu.uwm.universitydb.framework.db.command.DBCommand#getSQL()
     */
    @Override
    public String getSQL()
    {
        return SELECT_QUERY;
    }

    /*
     * (non-javadoc)
     * @see edu.uwm.universitydb.framework.db.command.DBCommand#setParameters(java.sql.PreparedStatement)
     */
    @Override
    public void setParameters(final PreparedStatement pStmt) throws SQLException
    {
        pStmt.setInt(1, mProjectNumber);

    }

}
/*
 * ============================================================================
 * Change History
 * ----------------------------------------------------------------------------
 * Apr 19, 2014   Shyam Nair
 * File created
 * ----------------------------------------------------------------------------
 */